//
//  SAMemberSetCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/6/22.
//

#import "SAMemberSetCell.h"
#import "SACommoditySpecialFeesModel.h"

@interface SAMemberSetCell ()

@property (nonatomic, strong) UILabel *levelLab;
@property (nonatomic, strong) UILabel *discountLab;
@property (nonatomic, strong) UILabel *growthLab;

@end

@implementation SAMemberSetCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SACommoditySpecialFeesModel *)model {
    _model = model;
    self.levelLab.text = model.name;
    NSArray *arr = [model.value componentsSeparatedByString:@","];
    if (arr.count > 2) {
        self.discountLab.text = arr[1];
        double growth = [arr[2] doubleValue];
        self.growthLab.text = [NSString stringWithFormat:@"%0.lf",growth/100];
    }else {
        self.discountLab.text = @"";
        self.growthLab.text = @"";
    }
}

-(void)initUI {
    UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScaleNum(40))];
    whiteView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:whiteView];
    for (int i = 0; i < 3; i++) {
        UILabel *titleLab = [[UILabel alloc] init];
        titleLab.font = kFont(15);
        titleLab.textColor = kBlackColor;
        [whiteView addSubview:titleLab];
        titleLab.textAlignment = NSTextAlignmentCenter;
        if (i == 0) {
            titleLab.frame = CGRectMake(kScaleNum(30), 0, kScaleNum(105), kScaleNum(40));
            self.levelLab = titleLab;
        }else if (i == 1) {
            titleLab.frame = CGRectMake(kScaleNum(135), 0, kScaleNum(105), kScaleNum(40));
            self.discountLab = titleLab;
        }else if (i == 2) {
            titleLab.frame = CGRectMake(kScaleNum(240), 0, kScaleNum(105), kScaleNum(40));
            self.growthLab = titleLab;
        }
    }
}

@end
